package com.example.leetcode;

import static jdk.nashorn.internal.objects.NativeRegExp.test;

public class HW01 {
    public static void main(String[] args) {
        int num =20;
        int a,b,c;
    StringBuffer stringBuffer = new StringBuffer();
            for (int i = 1; i < num; i++) {
                for (int j = i+1; j < num; j++) {
                    for (int z = j+1; z < num; z++) {

                        if (z<num){
                            int zsum =z*z;
                            if (zsum==(i*i+j*j)){
                                if ((test1(i,j)||test1(i,z)||test1(j,z))&&z>j&&j>i){
                                  stringBuffer.append(i).append(" ").append(j).append(" ").append(z).append("\n");
                                }
                            }
                        }

                    }
                }
            }

        System.out.println(stringBuffer.toString());

    }

    private static boolean test1(int i, int j) {
        int min = Math.min(i, j);
        for (int a = 2; a < min;a++) {
            if (j % a== 0 && i % a == 0) {
                return false;
            }
        }
       return true;
    }
}
